import smtplib
from email.header import Header
from email.mime.text import MIMEText

#发送邮件
class SendMail(object):
    def send_mail(HtmlFile):
        smtpserver='https://www.263.net/'
        sender='hujie@chinamcloud.com'
        username='hujie@chinamcloud.com'
        password='13478522128Hj!'
        subject='测试报告'
        receiver='1957832414@qq.com'
        f=open(HtmlFile,'rb')
        mail_body=f.read()
        mail_body=mail_body.decode('utf-8')
        f.close()
        msg=MIMEText(mail_body,'html','utf-8')
        msg['Subject']=Header(subject,'utf-8')
        msg['From']=sender
        msg['To']=receiver

        smtp=smtplib.SMTP()
        smtp.connect(smtpserver)
        smtp.login(username,password)
        smtp.sendmail(sender,receiver,msg.as_string())
        smtp.quit()